package cn.tonyandmoney.baidu.asr.model;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import cn.tonyandmoney.baidu.asr.entity.NluResult;

/**
 * 这个语音识别filter
 * 我们设置一定的过滤器
 */
public class AsrFilterInvocation extends AsrFilter {

    private List<AsrFilter> filters = new ArrayList<>();

    public void addFilter(AsrFilter filter) {
        filters.add(filter);
    }

    public void removeFilter(AsrFilter filter) {
        filters.remove(filter);
    }




    /**
     * 返回，true，则不执行后续的操作
     *
     * @return 是否继续执行
     */
    @Override
    public boolean doFilter(NluResult result) {
        Iterator<AsrFilter> temp = filters.iterator();
        if (temp.hasNext()){
            AsrFilter filter = temp.next();
            filter.filter(result,temp);
        }
        return false;
    }
}
